<?php
error_reporting(7);

if (!$_GET['action'] AND !$_POST['action']) {
        $_GET['action'] = "view";
}


if($_GET['action'] == "status"){
    require "common.php";
    require "tools/feedback/class.feedback.php";
    $feedback=new FEEDBACK($DB);

    $result=$feedback->setReply($_GET['id']);
    if($result){
        redirect("javascript:window.history.back()", "设置成功！");
    }else{
        redirect("javascript:window.history.back()", "设置失败！");
    }
}

if ($_GET[action] == "remove") {
        require "common.php"; 
        // START 检查权限
        if (!$perm->check_permission(NEWS, NEWS_WRITE)) {
                display_nopermission();
        }
        // END 检查权限
        $id=$_GET["id"];
        require "tools/feedback/class.feedback.php";
        $feedback=new FEEDBACK($DB);
        $result=$feedback->del($id);
        if($result){
            redirect("javascript:window.history.back()", "删除成功！");
        }else{
            redirect("javascript:window.history.back()", "删除失败！");
        }

}

if ($_GET[action] == "view") {
        $template_name = "feedback_view.htm";
        require "common.php";
        require "tools/feedback/class.feedback.php";
        $cate=$_GET["catetree"];
        $title=$_GET["title"];
        $customname=$_GET["customname"];
        $reply=$_GET["reply"];
        $add_time=$_GET["add_time"];
        // START 检查权限
        if (!$perm->check_permission(NEWS, NEWS_VIEW)) {
                display_nopermission();
        }
        // END 检查权限
        ///*****生成分类数据////
        require_once "tools/tree/sort.class.php";
        $tree = new SortClass($DB,'`t_reported_sys`');
        $selecttreelist=$tree->makeTreeSelect(28,"catetree");
        ///*****生成分类数据结束////

        if(!empty($cate)){
            $where.=" and cate='$cate'";
        }
        if(!empty($title)){
            $where.=" and title like '%$title%'";
        }
        if(!empty($customname)){
            $where.=" and customname like '%$customname%'";
        }
        if(!empty($add_time)){
            $where.=" and add_time>='$add_time'";
        }
        if(!empty($reply)){
            $where.=" and operator='$operator'";
        }
        $feedback=new FEEDBACK($DB);
        $result=$feedback->show($where);
        $tpl->assign($feedback->pager->result);
        $tpl->assign("selecttreelist",$selecttreelist);
        $tpl->assign("results", $result);
        $tpl->output();
}

?>